/* eslint-disable */
// @ts-nocheck
import Crypto from './crypto'
import './hmact'
import './sha1'
import { Base64 } from './base64'

let date = new Date()
date = date.setHours(date.getHours() + 999)
const extime = `${new Date(date).toISOString()}`
const policyText = {
  expiration: extime, // 设置该Policy的失效时间，超过这个失效时间之后，就没有办法通过这个policy上传文件了
  conditions: [
    ['content-length-range', 0, 1024 * 1024 * 100] // 设置上传文件的大小限制 ,超过100M的文件不能写入
  ]
}
const config = {
  accessid: '', // 修改成自己的
  accesskey: '', // 修改成自己的
  osshost: '', // 修改成自己的
  policyBase64: Base64.encode(JSON.stringify(policyText)),
  uploadFileSize: 1024 * 1000 * 10 // 上传文件大小限制 10M
}
const message = config.policyBase64
const bytes = Crypto.HMAC(Crypto.SHA1, message, config.accesskey, {
  asBytes: true
})
const signature = Crypto.util.bytesToBase64(bytes)
const timetamp = new Date().getTime()

const OSS = {
  name: 'aliyun',
  signature,
  host: config.osshost,
  accessid: config.accessid,
  policyBase64: config.policyBase64,
  uploadFileSize: config.uploadFileSize
}
export default OSS
